package com.software.thread.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.software.thread.R;

import java.util.ArrayList;
import java.util.List;

public class StudentListActivity extends AppCompatActivity {

    private List<String> studentList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_student_list);

        ListView lv_student_list = findViewById(R.id.lv_student_list);

        //初始化数据源
        initData();
        //创建适配器
        ArrayAdapter<String> adapter = new ArrayAdapter<>(
                this,
                android.R.layout.simple_list_item_1,
                studentList
        );
        lv_student_list.setAdapter(adapter);
    }

    private void initData() {
        studentList = new ArrayList<>();
        studentList.add("张三");
        studentList.add("李四");
        studentList.add("王五");

    }
}